local joy__canshi = fk.CreateSkill {

  name = "joy__canshi",

  tags = {  },

}



joy__canshi:addEffect(fk.DrawNCards, {
  name = "joy__canshi",
  anim_type = "drawcard",
  events = {fk.DrawNCards},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(joy__canshi.name) and table.find(player.room.alive_players, function (p)
      return p:isWounded() or (player:hasSkill("joy__guiming") and p.kingdom == "wu" )
    end)
  end,
  on_cost = function (self, event, target, player, data)
    local n = 0
    for _, p in ipairs(player.room.alive_players) do
      if p:isWounded() or (player:hasSkill("joy__guiming") and p.kingdom == "wu" ) then
        n = n + 1
      end
    end
    if player.room:askForSkillInvoke(player, joy__canshi.name, nil, "#joy__canshi-invoke:::"..n) then
      event:setCostData(self, n)
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    data.n = data.n + event:getCostData(self)
  end,
})

joy__canshi:addEffect(fk.CardUsing, {
  name = "#joy__canshi_delay",
  anim_type = "negative",
  events = {fk.CardUsing},
  can_trigger = function(self, event, target, player, data)
    return target == player and data.card.trueName == "slash" and
      player:usedSkillTimes(joy__canshi.name) > 0 and not player:isNude()
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player.room:askForDiscard(player, 1, 1, true, joy__canshi.name, false)
  end,
})

return joy__canshi